#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int findContentChildren(vector<int>& g, vector<int>& s) {
    sort(g.begin(), g.end());
    sort(s.begin(), s.end());
    int i = 0, j = 0;
    int ans = 0;
    while (i < g.size() && j < s.size())
    {
        if (s[j] >= g[i]) i++, j++;
        else j++;
    }
    return ans;
}

string optimalDivision(vector<int>& nums) {
    string s;
    if (nums.size() == 1)
        return to_string(nums[0]);
    else if (nums.size() == 2)
    {
        s += to_string(nums[0]);
        s += '/';
        s += to_string(nums[1]);
        return s;
    }
    else
    {
        s += to_string(nums[0]);
        s += '/';
        s += '(';
        for (int i = 1; i < nums.size(); i++)
        {
            s += to_string(nums[i]);
            s += '/';
        }
        s.erase(s.end() - 1);
        s += ')';
        return s;
    }
}

int jump(vector<int>& nums) {
    int left = 0, right = 0;
    int i = 0, max = nums[0], maxpos = 0;
    int ans = 0;
    while (i < nums.size())
    {
        while (left <= i && i <= right)
        {
            if (nums[i] > max) max = nums[i], maxpos = i;
            i++;
        }
        if (max + maxpos >= nums.size() - 1) break;
        left = right + 1;
        right = max + maxpos;
        max = nums[i], maxpos = i;
        ans++;
    }
    return ans + 1;
}

int main()
{
    vector<int> g{ 2,3,0,1,4 };
    //vector<int> s{ 1,1 };

    //findContentChildren(g, s);
   /* vector<int> v{ 100, 2 };
    string s;
    s += to_string(v[1]);
    s += '/';*/

    //optimalDivision(g);

    jump(g);
	return 0;
}